﻿@model Yes.Domain.Entity.CategoryEntity
@{
    ViewBag.Title = Model.Id>0? "修改分类" : "新增分类";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

<div class="main-wrap">

    <div class="crumb-wrap">
        <div class="crumb-list"><i class="icon-font"></i><a href="@(Url.Action("Index","Home"))">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="@(Url.Action("Index","Category"))">分类管理</a><span class="crumb-step">&gt;</span><span>@(ViewBag.Title)</span></div>
    </div>
    <div class="result-wrap">
        <div class="result-content">
            <form action="@(Url.Action("Add", "Category"))" method="post">
                <input name="id" value="@(Model.Id)" type="hidden">
                <table class="insert-table" width="100%">
                    <tbody>
                    <tr>
                        <th><i class="require-red">*</i>分类名：</th>
                        <td>
                            <input class="common-text required" id="name" name="name" size="50" value="@(Model.Name)" type="text">
                        </td>
                    </tr>
                    <tr>
                        <th>排序：</th>
                        <td><input class="common-text" name="sortid" size="50" value="@(Model.SortId)" type="text"></td>
                    </tr>
                    <tr>
                        <th></th>
                        <td>
                            <input class="btn btn-primary btn6 mr10" value="提交" type="button" id="addBtn">
                            <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                        </td>
                    </tr>
                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>

<script>
    $(function () {
        $(document).on('click', '#addBtn', function () {
            $.ajax({
                type: "POST",
                url: "@(Url.Action("Add","Category"))",
                data: $("form").serialize(),
                success: function (result) {
                    if (result.status) {
                        location.href = "@(Url.Action("Index"))";
                    } else {
                        var error = result.errorMessage;
                        if (result.data) {
                            error += "<br>" + result.data;
                        }
                        layer.alert(error, { icon: 5 });
                    }
                }
            });
        });
    });
</script>